www.gusucode.com > 落叶冰点万能企业网站内容管理系统 V9.1 > 落叶冰点万能企业网站内容管理系统 V9.1\code\admin\adminHTML\test4.asp
<% Server.ScriptTimeout=999999 Function GetBodyx(weburl) GetBodyx=GetBodyb(weburl) End Function bianma_reg="\<meta.+ charset= {0,}([^\""| |\>|\/]*).+\/{0,1}\>" title_reg="\<title\>(.*)\<\/title\>" Function GetCode(str,regstr) Dim Reg,serStr set Reg= new RegExp Reg.IgnoreCase = True Reg.MultiLine = True Reg.Pattern =regstr if Reg.test(str) then '若查询到匹配项 Set Cols = Reg.Execute(str) serStr=trim(Cols(0).SubMatches(0)) '使用匹配到的第一个匹配项 else '否则给个默认值gb2312,有点省懒法,如果页面没给出编码格式,想知道确实有点麻烦 serStr="gb2312" end if GetCode=serStr end function Function GetBodyb(weburl) GetBodyb="生成此页的html页时超时,无法获得内容" '创建对象 'Dim ObjXMLHTTP Set ObjXMLHTTP=Server.CreateObject("MSXML2.serverXMLHTTP") on error resume next ObjXMLHTTP.setTimeouts 20000, 20000, 20000, 2000 '请求文件 ObjXMLHTTP.Open "GET",weburl,false ObjXMLHTTP.send '得到结果 nd_http_200ed_ok=1 if err.number<>0 then err.clear nd_http_200ed_ok=0 GetBodyb="xmlhttp超时,无法获得内容" exit function end if if instr(1,lcase(ObjXMLHTTP.getResponseHeader("Content-Type")),"text/html",1)=0 then GetBodyb="非网页数据" exit function end if if ObjXMLHTTP.status>300 then nd_http_200ed_ok=0 end if GetBodybx1=ObjXMLHTTP.responseBody GetBodyax2 =ObjXMLHTTP.responseText ddd2=ObjXMLHTTP.getResponseHeader("Content-Length") ddd=ObjXMLHTTP.getAllResponseHeaders() %> <%=ddd%><hr> <%=ddd2%> <% encodeingxxx=GetCode(GetBodyax2,bianma_reg) GetBodyb=BytesToBstrc(GetBodybx1,encodeingxxx) set re=nothing '释放对象 Set ObjXMLHTTP=Nothing End Function Function BytesToBstrc(body,Cset) 'dim objstream set objstream = Server.CreateObject("adodb.stream") objstream.Type = 1 objstream.Mode =3 objstream.Open objstream.Write body objstream.Position = 0 objstream.Type = 2 objstream.Charset = Cset BytesToBstrc = objstream.ReadText objstream.Close set objstream = nothing End Function 'response.write GetBodyx("http://www.chinesent.com/forum/list-1.html") response.write GetBodyx("http://www.aspcpu.com/ajaxweb/hsj_v3_11s.rar") %>